import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../components/root_page_head.dart';
import '../sub_pages/singer_page.dart';
import '../sub_pages/song_page.dart';

class MusicPage extends StatefulWidget {
  const MusicPage({Key? key}) : super(key: key);

  @override
  _MusicPageState createState() => _MusicPageState();
}

const List<Tab> _tabs = [
  Tab(
    text: "歌曲",
  ),
  Tab(
    text: "歌手",
  )
];
final List<Widget> _tabContent = [
  SongPage(),
  SingerPage(),
];

class _MusicPageState extends State<MusicPage> with TickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(
      length: _tabs.length,
      vsync: this,
      initialIndex: 1,
    );
  }

  @override
  void dispose() {
    _tabController.dispose();
    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: RootPageHead(),
        bottom: TabBar(
          tabs: _tabs,
          controller: _tabController,
          isScrollable: true,
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: _tabContent,
      ),
    );
  }
}
